package dk.dtu.is.jjmvcp.model;

import java.io.Serializable;


/**
 * This is the <i>model</i> of this application. </br></br>
 * 
 * It is a simple object with only one integer property.</br>
 * This property is {@link #myValueOne myValueOne} and has a Property Change event attached to it </br></br>
 * 
 * @author dsac
 */
public class MyJavaBeanModel extends BeanSupport implements Serializable {
	/**
	 * Default serialVersion
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * A simple property to test the Property Change event.
	 */
	private Integer myValueOne = null;
	
	/**
	 * Default constructor
	 */
	public MyJavaBeanModel() {
		
	}

	/**
	 * Getter method for myValueOne
	 * @return the value of myValueOne
	 */
	public Integer getMyValueOne() {
		return myValueOne;
	}

	/**
	 * Setter method for myValueOne. </br></br>
	 * When this property is set , this method fires the Property Change event
	 * 
	 * @param myValueOne the value of myValueOne
	 * 
	 */
	public void setMyValueOne(Integer myValueOne) {
		Integer oldValue = this.myValueOne;
		Integer newValue = myValueOne;
		this.myValueOne = newValue;
		pcs.firePropertyChange("myValueOne", oldValue, newValue);
	}
	
	/**
	 * It copies the properties of {@param myJavaBeanModel} into the current object.
	 * This will trigger a Property Change Event for each property being updated.
	 * 
	 * @param myJavaBeanModel the bean from which to copy properties
	 * 
	 */
	public void copyValuesFrom(MyJavaBeanModel myJavaBeanModel)
	{
		// in this case it is only one property.
		// Should the Bean have more properties, they should be added hereinafter
		this.setMyValueOne(myJavaBeanModel.getMyValueOne());
	}
}
